<template>
	<view class="page">
		<view class="top">
			<view class="success"><image src="../../static/image/ok.png"></image>领取成功</view>
			<view class="tips">工作人员将尽快与您联系!</view>
		</view>
		<view class="banner" v-if="imgUrl">
			<image class="banner-img" mode="widthFix" :src="imgUrl"></image>
		</view>
		<view class="img-box" v-if="!imgUrl">
			<image mode="widthFix" :src="bannerInfo.cover"></image>
		</view>
		<view class="car-info">
			<view class="name">{{bannerInfo.style_name}} | 限时优惠</view>
			<view class="jietu" v-if="imgUrl">请截图保存优惠信息</view>
		</view>
		<view v-if="bannerInfo.act_is_show">
			<view class="mask" v-show="isGuang">
				<view class="guang-box">
					<view class="image-box">
						<image style="height: 804rpx;" mode="heightFix"  class="guang-tu" :src="bannerInfo.act_banner"></image>
						<button plain="true" class="guang-btn" open-type="openAwemeUserProfile" @openawemeuserprofile="eventHandler" :data-aweme-id="infoData.douyin_num">立即私信主播领取</button>
					</view>
					<image @click="closeGuang" class="cha" src="../../static/image/cha.png" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const Api = require('../../utils/api.js');
	const request = require('../../utils/request.js');
	
	export default {
		data(){
			return {
				style_hid: '',
				carInfo: {},
				imgUrl: '',
				infoData: {},
				bannerInfo: {},
				isGuang: true,
				awemeId: ''
			}
		},
		onLoad(options) {
			console.log(options, '领优惠')
			this.imgUrl = options.imgUrl
			this.style_hid = options.style_hid
			this.infoData = options
			console.log(this.infoData, "infodata")
			this.getSuccessData()
		},
		methods: {
			getCarInfo() {
				request.http({
					url:Api.car_success_info,
					header: {
						// 'content-type': 'application/x-www-form-urlencoded',
					},
					type: 'GET',
					data: {
						style_hid:  this.style_hid
					},
					 
				}).then(res => {
					// console.log(res, '333')
					console.log(res.data, 'che')
					this.carInfo = res.data
					
				})
			},
			
			getSuccessData () {
				
				request.http({
					url:Api.leave_success,
					header: {
						// 'content-type': 'application/x-www-form-urlencoded',
					},
					type: 'GET',
					data: {
						style_hid:  this.style_hid,
						special_hid: this.infoData.special_hid,
						nickname: this.infoData.douyin_name,
						phone: this.infoData.phone,
						is_send_sms: this.infoData.is_send_sms,
						kol_id: this.infoData.kol_id
					},
					 
				}).then(res => {
					// console.log(res, '333')
					console.log(res.data, 'che')
					this.bannerInfo = res.data
					
				})
			},
			
			closeGuang() {
				this.isGuang = false
			},
			eventHandler(e) {
			    if (e.detail.errNo) {
				  console.log("跳转抖音号个人页失败", e.detail);
				} else {
				  console.log("跳转抖音号个人页成功");
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		width: 100%;
		height: 100vh;
		background: #fff;
		box-sizing: border-box;
		.top{
			width: 100%;
			display:flex;
			flex-direction: column;
			align-items: center;
			.success {
				display: flex;
				align-items: center;
				font-weight: 500;
				font-size: 40rpx;
				color: #222526;;
				margin-top: 64rpx;
				image {
					width: 48rpx;
					height: 48rpx;
					margin-right: 16rpx;
				}
			}
			.tips{ 
				font-size: 28rpx;
				color: #222526;
				margin-top: 24rpx;
			}
		}
		
		.banner {
			width: 100%;
			padding: 0 46rpx;
			box-sizing: border-box;
			margin-top: 40rpx;
			.banner-img {
				width: 100%;
				border-radius: 16rpx;
			}
		}
		
		.img-box {
			width: 100%;
			margin: 40rpx 0;
			text-align:center;
			image {
				width: 440rpx;
				height: auto;
				
			}
		}
		
		.car-info {
			width: 100%;
			margin-top: 20rpx;
			.name {
				width: 100%;
				text-align: center;
				font-weight: 500;
				font-size: 28rpx;
				color: #222526;
			}
			.jietu {
				font-weight: 400;
				font-size: 24rpx;
				color: #6E7175;
				margin-top: 20rpx;
				text-align: center;
			}
		}
		
		.mask {
			width: 100%;
			height: 100vh;
			background: rgba(0, 0, 0, .4);
			
			position: fixed;
			top:0;
			left: 0;
			.guang-box {
				
				position: absolute;
				top: 58%;
				left: 50%;
				transform: translate(-50%, -58%);
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				.image-box{
					margin-top:-160rpx;
					position: relative;
					.guang-btn {
						position: absolute;
						bottom: 84rpx;
						left:50%;
						transform: translateX(-50%);
						width: 440rpx;
						height: 80rpx;
						background-image: linear-gradient(90deg, #8D5433 0%, #5D2602 100%);
						border-radius: 40rpx;
						font-size: 30rpx;
						color: #FFFFFF;
						line-height: 80rpx;
					
					}
				}
				.cha {
					width: 64rpx;
					height: 64rpx;
					margin-top: 20rpx;
				}
			}
		}
	}
</style>

<style>	
	button::after {
	      border: none;
	}
</style>